﻿Public Class Historial_Solicitudes_T'
    Inherits System.Web.UI.Page
    Public Slid As Integer = 1
    Public nombre As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1userid.Text = seguridad.usuarioid1
        seguridad.verificapermisos()
    End Sub



    Protected Sub ASPxButton1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton1.Click



        Try
            Dim fecha As String
            fecha = Date.Today.ToString("dd/MM/yyyy")
            Dim userid As String = 1 'seguridad.usuarioid1.ToString
            Dim Solicitudid As Integer = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("solicitudid"))
            Dim tablaasignaciones As New DataSet1TableAdapters.asignacionesTableAdapter
            Dim tablasalici As New DataSet1TableAdapters.solicitudesTableAdapter
            Dim asignacionid As Integer = (tablaasignaciones.ScalarQuerySumaTodasLasAsignaciones() + 1)
            Dim query1 As String = String.Format("INSERT INTO asignaciones(usuarioid, fecha, descripcion, solicitudid ,asignacionid) values('{0}','{1}','{2}','{3}','{4}')",
                                       userid,
                                       fecha,
                                       "Ninguno",
                                       Solicitudid,
                                       asignacionid)
            Dim con As New Devart.Data.PostgreSql.PgSqlConnection(seguridad.conexion) ' hacemos la conexion , pero la traemos desde clase seguridad
            con.Open()
            Dim Ejec1 As New Devart.Data.PostgreSql.PgSqlCommand(query1, con)
            Ejec1.ExecuteNonQuery()
            con.Close()
            tablasalici.UpdateQueryEstadoEnProceso("En proceso", Solicitudid)
            ASPxGridView1.DataBind()
        Catch ex As Exception
            MsgBox("No se pudo insertar en la base de datos ")
        End Try



    End Sub












    Protected Sub ASPxButton2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton2.Click

    End Sub

    Protected Sub ASPxPopupControl1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxPopupControl1.Load
        Label3Solicitudid.Text = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("solicitudid"))
        Label4Fecha.Text = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("fecha"))
        Label8Hora.Text = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("hora"))
        TextBox1.Text = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("descripcion"))
        'TextBox1.Text=ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("descripcion"))
    End Sub

    Protected Sub ASPxButton3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ASPxButton3.Click
        Dim tablasolicitu As New DataSet1TableAdapters.solicitudesTableAdapter
        Dim idsolicitud As Integer
        idsolicitud = ASPxGridView1.GetRowValues(ASPxGridView1.FocusedRowIndex, ("solicitudid"))
        tablasolicitu.UpdateQueryPermiso("Requiere permiso", idsolicitud)
        ASPxGridView1.DataBind()
        ASPxGridView2.DataBind()


    End Sub
End Class